package self.Lunastic.HexaSweeper.Unit;

import self.Lunastic.HexaSweeper.Manager.*;

import javax.swing.*;
import java.awt.*;

public class ButtonControl extends ButtonBase{
    public ButtonControl(int x, int y, int w, int h, String t){
        super(x,y,w,h);
        this.setHorizontalTextPosition(SwingConstants.CENTER);
        this.setForeground(StyleOption.BUTTON_COLOR);
        this.setFont(new Font(StyleOption.BUTTON_FONT, Font.BOLD, h/2));
        this.setText(t);
    }

    @Override
    protected void extraPaint() {
        g2d.setColor(this.getBackgroundColor());
        g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
    }
    // 根据状态获取背景颜色
    private Color getBackgroundColor(){
        // 被点击
        if(this._leftPress){ return StyleOption.BUTTON_CLICK; }
        // 被悬停
        else if(this._hover){ return StyleOption.BUTTON_HOVER; }
        // 默认
        return StyleOption.BUTTON_COVER;
    }
}
